<!DOCTYPE html>
<html lang="en">
<head>
    <!--
    author：一给我里giaogiao的阿辉
    time:2019/12/30
    Wish me Happy Birthday! 24前途一片光明！
    -->
    <meta charset="UTF-8">
    <title>泉港二中点名生成器</title>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css">
    <style>
        body{
            width: 100%;
            background-color: white;
        }

        .container{
            position: relative;
            width: 20%;
            left:40%;
            /*background-color: #00FF00;*/
        }

        #form-layui{
            width: 100%;
        }
    </style>
</head>
<body>
    <p id="demo" style="font-size: 40px;position: absolute; left:50px; top:50px"></p>
    <div class = "container" style="text-align: center;margin-top: 100px">

        <div class ="layui-inline" id="form-layui">
            <input type = "text"  id="fafa" class="layui-input"  placeholder="请输入起始学号" value="" style="margin-bottom: 10px;width: 100%;text-align: center"/>
            <input type = "text"  id="gaga" class="layui-input"  placeholder="请输入结束学号" value="" style="width: 100%;text-align: center"/>
            <button  class="layui-btn" onclick="myFunction()" style="margin-top: 30px;width: 100%;">点我点我</button>
        </div>


        <img src="images/background.gif" width="600px" height="400px">
    </div>
</body>



<script>
    layui.use(['layer', 'form'], function(){
        var layer = layui.layer
            ,form = layui.form;

    });

    function myFunction(){
        var startNumber  =  document.getElementById("fafa").value;
        var endNumber  =  document.getElementById("gaga").value;


        if(startNumber== null || startNumber == ""){
            startNumber = "1" ;
        }
        if(endNumber== null || endNumber == "" ){
            alert("请输入结束学号哦！boy！");
        }

        var x=document.getElementById("demo");
        var result = random(startNumber,endNumber);
        x.innerHTML= result;
    }

    function random(lower, upper) {
        var y = Math.random();
        var result1 = y*(upper-lower+1);
        var result2 = parseInt(result1)+parseInt(lower);
        var result3 = Math.floor(result2);
        return result3;
        /*return Math.floor(Math.random() * (upper - lower+1)) + lower;*/
    }

</script>
<!--    <script src="index.js" type="text/javascript"></script>-->
</html>
